<template>
  <comNavigation>
    <template v-slot:title>
      修改昵称
    </template>
    <template v-slot:right>
      <van-button round style="padding: 10px;border: 1px solid #74cec3;background: #e9f7f6;color: #74cec3;" @click="add"
        size="mini">保存</van-button>
    </template>
  </comNavigation>

  <van-cell-group inset>
    <van-field v-model="userName" clearable @clear="clear" label="用户昵称" />
  </van-cell-group>
  <div>

  </div>

</template>

<script setup lang="ts">
import { ref } from 'vue'
// 路由
import { useRoute } from 'vue-router';
const route = useRoute()
// 导航
import comNavigation from '@/components/common/com-navigationBar/com-navigation.vue'

let userName = ref(route.params.keyword)
const clear = () => {
  userName.value = ''
}
import { showToast } from 'vant';


import { getpatientUpdateUserNameAPI } from '@/api/my'
import router from '@/router';
const add = async () => {
  const res = await getpatientUpdateUserNameAPI(userName.value)

  if (res.data.code === 10000) {
    showToast('修改成功');
  }

  setTimeout(() => {
    router.go(-1)
  }, 1000);

}
</script>

<style>
.van-field {
  border-bottom: 1px solid #cdc8c8;
}
</style>
